class Solution {
public:
    int maxDivScore(vector<int>& nums, vector<int>& divisors) {
        int ma = 0;
        int res = 1e9;
        bool f = 0;
        for (auto x : divisors) {
            int ans = 0;
            for (auto y : nums) {
                if (y % x == 0)ans++;
            }

            if (ans > ma) {
                ma = ans;
                res = x;
            }
            else if (ans == ma) {
                res = min(x, res);
            }
        }
        return res;
    }
};